package com.ruoyi.project.dict.zicorrectlog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dict.zicorrectlog.domain.ZiCorrectLog;
import com.ruoyi.project.dict.zicorrectlog.service.IZiCorrectLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 生字勘误Controller
 * 
 * @author shixiangwen
 * @date 2021-10-20
 */
@Controller
@RequestMapping("/dict/zicorrectlog")
public class ZiCorrectLogController extends BaseController
{
    private String prefix = "dict/zicorrectlog";

    @Autowired
    private IZiCorrectLogService ziCorrectLogService;

    @RequiresPermissions("dict:zicorrectlog:view")
    @GetMapping()
    public String zicorrectlog()
    {
        return prefix + "/zicorrectlog";
    }

    /**
     * 查询生字勘误列表
     */
    @RequiresPermissions("dict:zicorrectlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZiCorrectLog ziCorrectLog)
    {
        startPage();
        List<ZiCorrectLog> list = ziCorrectLogService.selectZiCorrectLogList(ziCorrectLog);
        return getDataTable(list);
    }

    /**
     * 导出生字勘误列表
     */
    @RequiresPermissions("dict:zicorrectlog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZiCorrectLog ziCorrectLog)
    {
        List<ZiCorrectLog> list = ziCorrectLogService.selectZiCorrectLogList(ziCorrectLog);
        ExcelUtil<ZiCorrectLog> util = new ExcelUtil<ZiCorrectLog>(ZiCorrectLog.class);
        return util.exportExcel(list, "zicorrectlog");
    }

    /**
     * 新增生字勘误
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存生字勘误
     */
    @RequiresPermissions("dict:zicorrectlog:add")
    @Log(title = "生字勘误", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZiCorrectLog ziCorrectLog)
    {
        return toAjax(ziCorrectLogService.insertZiCorrectLog(ziCorrectLog));
    }

    /**
     * 修改生字勘误
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZiCorrectLog ziCorrectLog = ziCorrectLogService.selectZiCorrectLogById(id);
        mmap.put("ziCorrectLog", ziCorrectLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存生字勘误
     */
    @RequiresPermissions("dict:zicorrectlog:edit")
    @Log(title = "生字勘误", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZiCorrectLog ziCorrectLog)
    {
        return toAjax(ziCorrectLogService.updateZiCorrectLog(ziCorrectLog));
    }

    /**
     * 删除生字勘误
     */
    @RequiresPermissions("dict:zicorrectlog:remove")
    @Log(title = "生字勘误", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ziCorrectLogService.deleteZiCorrectLogByIds(ids));
    }
}
